//
//  UIView+ScreensShot.m
//  MyFunctionDemo
//
//  Created by Ting Han on 2017/9/2.
//  Copyright © 2017年 Ting Han. All rights reserved.
//

#import "UIView+ScreensShot.h"

@implementation UIView (ScreensShot)

- (UIImage *)screenShot{
    if (self && self.frame.size.width && self.frame.size.height) {
        //size;是否模糊;scale =0.0的意思就是自动调整缩放因子以适配显示屏
        UIGraphicsBeginImageContextWithOptions(self.frame.size, NO, 0);
        //把View绘制到context
        [self.layer renderInContext:UIGraphicsGetCurrentContext()];
        UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
         UIGraphicsEndImageContext();
        return image;
    }else{
        return nil;
    }

}

@end
